package com.socks.okhttp.plus.parser;

import android.util.Log;

import com.estar.app.appsrvycabx.domain.DataVO;
import com.socks.okhttp.plus.parser.OkBaseParser;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

import java.io.IOException;

import okhttp3.Response;

/**
 * Created by zhaokaiqiang on 15/11/22.
 */
public abstract class OkXmlParser<T> extends OkBaseParser<T> {

    protected XStream xStream;
    String className = "com.estar.app.appsrvycabx.domain.DataVO";
    public OkXmlParser() {
        //xStream = new XStream();//这里改一下就可以了  ，参照一下以前的移动查勘
    	xStream = new XStream(new DomDriver());
		//String name = className;
//    	xStream.alias(className, DataVO.class);
        xStream.alias(DataVO.class.getName(), DataVO.class);
    }

    @SuppressWarnings("unchecked")
	@Override
    public T parse(Response response) throws IOException {
        String body = response.body().string();
        return (T)xStream.fromXML(body);
    }
}